<%--
  Created by IntelliJ IDEA.
  User: 10944
  Date: 2021/8/12
  Time: 19:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
%>
<script src="<%=path%>/static/jquery/jquery-3.6.0.min.js"></script>
<link href="<%=path%>/static/modal/bootstrap-4.6.0-dist/css/bootstrap.min.css" rel="stylesheet"/>

<html>
<head>
    <title>修改菜品</title>
</head>
<body>
<div class="page-container">
    <h2 class="mt-3 mb-3">修改菜品</h2>
    <hr>
    <div class="container-md">
        <div id="filePickerContainer">
            <form class="form" onsubmit="return false;">
                <div class="form-group">
                    <label>菜品ID</label>
                    <input type="text" id="menusId" name="menusId" value="${menus.menusId}" class="form-control"
                           readonly>
                </div>
                <div class="form-group">
                    <label>菜名</label>
                    <input type="text" id="menusName" name="menusName" value="${menus.menusName}" class="form-control">
                </div>
                <div class="form-group">
                    <label>类别</label>
                    <input type="text" id="menusClass" name="menusClass" value="${menus.menusClass}"
                           class="form-control">
                </div>
                <div class="form-group">
                    <label>成本</label>
                    <input type="text" id="menusCost" name="menusCost" value="${menus.menusCost}" class="form-control">
                </div>
                <div class="form-group">
                    <label>售价</label>
                    <input type="text" id="menusPrice" name="menusPrice" value="${menus.menusPrice}"
                           class="form-control">
                </div>
                    <div class="col">
                        <div class="laydate-footer-btns right-button">
                            <button class="btn btn-success float-right btn-lg" type="button" onclick="update()">提交</button>
                        </div>
                    </div>
            </form>
        </div>
    </div>
</div>
<script>
    function update() {
        $.ajax({
            url: "update",
            method: "post",
            type: "text",
            data: {
                menusId: $("#menusId").val(),
                menusName: $("#menusName").val(),
                menusClass: $("#menusClass").val(),
                menusCost: $("#menusCost").val(),
                menusPrice: $("#menusPrice").val(),
            },
            success: function (data) {
                if (data == "ok") {
                    alert("修改成功了!");
                    // window.location.href="all";
                    parent.location.reload()
                    layer_close();
                } else {
                    alert("修改失败了!");
                }
            }
        })
    }
</script>
</body>
</html>
